package com.is.add.util;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

public class SMSManager {
	public final static String SMS_USERNAME="hbayd001";
	public final static String SMS_PASSWORD="000000";
	public final static String SMS_CHECKCODE="zjmkatyd2016";
	public static SMSResult send(String phone,String content){
		String result;
		String messageContent = "";
		try {
			messageContent = URLEncoder.encode(content, "UTF-8");
			String md5=MD5.getMD5ofStr(SMS_USERNAME+SMS_PASSWORD+SMS_CHECKCODE);
			String param="{\"username\":\""+SMS_USERNAME+"\",\"pwd\":\""+SMS_PASSWORD+"\",\"phone\":\""+phone+"\",\"content\":\""+messageContent+"\",\"md5\":\""+md5+"\"}";
			result = HttpUtil.postJson("http://customer.hjz518.com/SmsService.asmx/MerotekSms", param, "UTF-8", "UTF-8");
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
			return new SMSResult("{\"d\":\"{\"retcode\":\"-1\",\"retmessage\":\"内容转换失败\",\"redata\":[]}\"}");
		}
		System.out.println("-----------------------------------------------------------");
		System.out.println("发送短信给："+phone);
		System.out.println("成功发送短信："+result);
		System.out.println("-----------------------------------------------------------");
		return new SMSResult(result);
	}
/*	public static void main(String[] args){
		SMSResult result=SMSManager.send("18086620891","你好");
		System.out.println(result);
	}*/
}
